
/**
 * 查询解决方案各个分类里面的全部解决方案,限制显示4个方案(pc端）
 */
var categoryID=getUrlParam('categoryID');
(function () {
    $.ajax({
        type:'GET',
        dataType:'json',
        url:'/rest/front/plan/selectAllList',
        data:{
            categoryID:categoryID
        },
        success:function (data) {
            var list=data.data,html='',id='';
            $.each(list,function (i, e) {
                if(i<4) {
                    if (i == 0) {
                        id = e.id;
                        queryPlanMobile(id);
                    }
                    html += '<li data-id="' + e.id + '">' + e.name + '</li>';
                    if (i > 2) {
                        return false;
                    }
                }
            });
            $('.solution-nav').html(html).find('li').eq(0).addClass('active');
            var imgHtml='<img src="/'+data.data[0].headImage+'">';
            $(".solution-bg").html(imgHtml);
            return queryplan(id);
        }
    })
})();
/**
 * 根据id，显示单个方案的内容(pc端）
 */
function queryplan(id) {
    $.ajax({
        type:'GET',
        url:'/rest/front/plan/selectDetail',
        data:{id:id},
        dataType:'json',
        success:function (data) {
            var planList=data.data,
                professionImgsArr=[],//声明行业图片数组
                professionNameArr=[],//声明行业名称数组
                firstArr=[],//声明行业内容1数组
                secondArr=[],//声明行业内容2数组
                thirdArr=[],//声明行业内容2数组
                professionHtml="",
                productID=planList.productID,//声明行业内容
                customerImageArr=[],//声明客户案例图片的数组
                customerHtml="";
                professionImgsArr=planList.professionImage.split(",");
                customerImageArr=planList.customerImage.split(",");//分割客户案例图片
                professionNameArr=planList.professionName.split(";");
                firstArr=planList.firstProfessionContent.split(";");//声明行业内容1
                secondArr=planList.secondProfessionContent.split(";");//声明行业内容2
                thirdArr=planList.thirdProfessionContent.split(";");//声明行业内容3
            //行业需求的渲染
            for (var j = 0; j < professionImgsArr.length; j++) {
                professionHtml+= '<li class="solution-li"><div class="pull-left"><img src="/'+professionImgsArr[j]+'" class="pull-left" style="width: 37px;height:37px;"><h5 class="pull-left">'+professionNameArr[j]+'</h5></div><ul class="pull-left">'+
                '<li><span class="circle"></span><p>'+firstArr[j]+'</p></li>'+
              '<li><span class="circle"></span><p>'+secondArr[j]+'</p></li>'+
               '<li><div class="circle"></div><p class="">'+thirdArr[j]+'</p></li>'+
              '</ul></li>';
            }
            $(".profession-ul").html(professionHtml);
            $(".profession-ul  p").each(function(){
                var maxwidth=78;
                if($(this).text().length >maxwidth){
                    $(this).text($(this).text().substring(0,maxwidth));
                    $(this).html($(this).html()+'...');
                }
            });
            //客户案例的轮播图
            for (var i in customerImageArr) {
                customerHtml+= '<div class="swiper-slide"><img src="/' +customerImageArr[i] + '"></div>';
            }
            $(".casePc-swiper-wrapper").html(customerHtml);
            $(".planIntroduce-pc").html(planList.content);      //解决方案的编辑器

            //查询产品推荐
            queryProduct(id)
        }
    })
}
function queryPlanMobile(id){
    $.ajax({
        type:'GET',
        url:'/rest/front/plan/selectDetail',
        data:{id:id},
        dataType:'json',
        success:function (data) {
            var planList=data.data,
                professionImgsArr=[],//声明行业图片数组
                professionNameArr=[],//声明行业名称数组
                firstArr=[],//声明行业内容1数组
                secondArr=[],//声明行业内容2数组
                thirdArr=[],//声明行业内容2数组
                professionHtml="",
                productID=planList.productID,//声明行业内容
                customerImageArr=[],//声明客户案例图片的数组
                customerHtml="";
            professionImgsArr=planList.professionImage.split(",");
            customerImageArr=planList.customerImage.split(",");//分割客户案例图片
            professionNameArr=planList.professionName.split(";");
            firstArr=planList.firstProfessionContent.split(";");//声明行业内容1
            secondArr=planList.secondProfessionContent.split(";");//声明行业内容2
            thirdArr=planList.thirdProfessionContent.split(";");//声明行业内容3
            //行业需求的渲染
            for (var j = 0; j < professionImgsArr.length; j++) {
                professionHtml+= '<div class="solution-industryList"><div class="solution-icon"><img src="/'+professionImgsArr[j]+'" class="pull-left"><h5 class="pull-left">'+professionNameArr[j]+'</h5></div><ul class="solution-industryul ">'+
                    '<li><span class="circle"></span><p>'+firstArr[j]+'</p></li>'+
                    '<li><span class="circle"></span><p>'+secondArr[j]+'</p></li>'+
                    '<li><span class="circle"></span><p>'+thirdArr[j]+'</p></li>'+
                    '</ul></div>';
            }
            $(".professionMobile-ul").html(professionHtml);
            //客户案例的轮播图
            for (var i in customerImageArr) {
                customerHtml+= '<div class="swiper-slide"><img src="/' +customerImageArr[i] + '"></div>';
            }
            $(".caseMobile-swiper-wrapper").html(customerHtml);

            $(".planIntroduce-mobile").html(planList.content);      //解决方案的编辑器
            //查询产品推荐
            queryProductMobile(id)
        }
    })
}
/**
 * 参数productID
 * 查询产品推荐(pc端）
 */
function queryProduct(id){
    $.ajax({
        type:'GET',
        url:'/rest/front/plan/selectProductList',
        data:{id:id},
        dataType:'json',
        success:function(data){
            var productList=data.data,
                productHtml="";
            $.each(productList,function(i,o){
                if(i<3){
                    productHtml+='<li><a  href="../cpzx/cpxl/'+o.id+'.html"><img src="/'+o.headImage+'"><div class="series-text pull-right">'+
                        '<h5>'+o.name+'</h5><p>'+o.introduce+'</p><span>MORE></span></div></a></li>'
                }else{
                    return false;
                }
            });
            $(".recommendPc-ul").html(productHtml);
            $(".recommendPc-ul  p").each(function(){
                var maxwidth=38;
                if($(this).text().length >maxwidth){
                    $(this).text($(this).text().substring(0,maxwidth));
                    $(this).html($(this).html()+'...');
                }
            });
        }
    })
}
/**
 * 参数productID
 * 查询产品推荐(移动端）
 */
function queryProductMobile(id){
    $.ajax({
        type:'GET',
        url:'/rest/front/plan/selectProductList',
        data:{id:id},
        dataType:'json',
        success:function(data){
            var productList=data.data,
                productHtml="";
            $.each(productList,function(i,o){
                    productHtml+='<div class="swiper-slide"> <div class="recommend-list">'+
                        '<img src="/'+o.headImage+'" class=" pull-left"> <div class="series-text pull-left">'+
                        '<h5>'+o.name+'</h5><p>'+o.introduce+'</p> <span>MORE></span></div></div></div>'

            });
            $(".recommendMobile").html(productHtml);
        }
    })
}
(function () {
    var swiper = new Swiper('.recommendMobile-swiper', {
        paginationClickable: true,
        nextButton: '.recommendMobile-next',
        prevButton: '.recommendMobile-prev',
        autoHeight: false, //enable auto height
        speed: 2000,
        loop: true,
        observer:true,
        observeParents:true,
        // autoplayDisableOnInteraction : true,//开始自动播放,等到点击时不自动播放
        // autoplay:1500
    });
    var swiper1 = new Swiper('.project-swiper-container', {
        pagination: '.project-swiper-pagination',
        slidesPerView: 4,
        paginationClickable: true,
        nextButton: '.swiper-button-next',
        prevButton: '.swiper-button-prev',
        autoHeight: false, //enable auto height
        speed: 2000,
        loop: true,
        observer:true,
        observeParents:true,
        // autoplayDisableOnInteraction : true,//开始自动播放,等到点击时不自动播放
        // autoplay:1500
    });
    var swiperMobile = new Swiper('.clientSouMobile-swiper', {
        slidesPerView: 2,
        pagination: '.clientSouMobile-pagination',
        paginationClickable: true,
        autoplayDisableOnInteraction: true,//开始自动播放,等到点击时不自动播放
        autoplay: 1500
    });
    $(".menu-dropdown-left a").click(function(){
        $(this).addClass('active').siblings().removeClass('active');
    });
    $('.solution-nav').on('click', 'li', function() {
        var id=$(this).data('id');
        $(this).addClass('active').siblings().removeClass('active');
        queryplan(id);
    })
})();